/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import java.util.ArrayList;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
 *
 * @author Gautier
 */
public class GroupList extends JList implements ListSelectionListener{
    ArrayList<String> a;
    private DefaultListModel l1;
    private String s1, s2, s3, s4;
    private ContactList cl;

    public GroupList( ContactList c){
        super();
        cl=c;
        l1 = new DefaultListModel();
        s1="Family";
        s2="Friends";
        s3="Work";
        s4="Zoo";
        l1.addElement(s1);
        l1.addElement(s2);
        l1.addElement(s3);
        l1.addElement(s4);
        this.setModel(l1);
        this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.addListSelectionListener(this);
    }

    public DefaultListModel getL1() {
        return l1;
    }

    public void setL1(DefaultListModel l1) {
        this.l1 = l1;
    }

    @Override
    public void valueChanged(ListSelectionEvent e) {
        System.out.println(((GroupList)e.getSource()).getSelectedIndex());
        cl.groupActive=((GroupList)e.getSource()).getSelectedIndex();
        cl.setUpList(((GroupList)e.getSource()).getSelectedIndex());
    }
    
    
}
